﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ENTITY;
using System.Data;
using System.Data.SqlClient;

namespace MODELS
{
    public class MOD_chuong
    {
        private dbConnect dbConn;
        public MOD_chuong()
        {
            dbConn = new dbConnect();
        }

        public DataTable SelectByID(string strSQL)
        {
            return dbConn.GetData(strSQL);
        }
        public DataTable GetData()
        {
            return dbConn.GetData("Chuong_SelectAll",null);
        }
        // ado.net
        public int ExecuteSQL(EN_chuong obj_En)
        {
            SqlParameter[] para = { 
                                    new SqlParameter("MaMon",obj_En.MaMon),
                                    new SqlParameter("MaChuong",obj_En.MaChuong),
                                    new SqlParameter("TenChuong",obj_En.TenChuong),
                                    new SqlParameter("NoiDung",obj_En.NoiDung),
                                    new SqlParameter("Video",obj_En.Video)
                                  };
            return dbConn.ExecuteSQL("Chuong_Insert", para);
        }

        public int Update(EN_chuong obj_En)
        {
            SqlParameter[] para = {
                                    new SqlParameter("MaChuong",obj_En.MaChuong),
                                    new SqlParameter("TenChuong",obj_En.TenChuong),
                                    new SqlParameter("NoiDung",obj_En.NoiDung),
                                     new SqlParameter("Video",obj_En.Video)
                                  };
            return dbConn.ExecuteSQL("Chuong_Update", para);
        }

        public int Delete(EN_chuong obj_En)
        {
            SqlParameter[] para = { 
                                    new SqlParameter("MaChuong", obj_En.MaChuong)
                                  };
            return dbConn.ExecuteSQL("Chuong_Delete", para);
        }
    }
}
